package com.sinoair.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.MultipartConfigElement;

/**
 * layuiDemo
 * 文件上传配置
 * <pre>
 *  Version         Date            Author          Description
 * ---------------------------------------------------------------------------------------
 *  1.0.0           2017/09/10     senlin        -文件上传配置
 * </pre>
 *
 * @author senlin
 * @version 1.0.0 2017/9/10 0010 8:24
 * @date 2017/9/10 0010 8:24
 * @since 1.0.0
 */
@Configuration
public class FileUploadConfiguration {

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        // 设置文件大小限制 ,超出设置页面会抛出异常信息，
        // 这样在文件上传的地方就需要进行异常信息的处理了;
        factory.setMaxFileSize("256MB"); // KB,MB
        /// 设置总上传数据总大小
        factory.setMaxRequestSize("512MB");
        // Sets the directory location where files will be stored.
//         factory.setLocation("E://test//attached//");
        return factory.createMultipartConfig();
    }
}
